/*
 * jxSwing Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxSwing.component.table.cellRenderer;

import javax.swing.SwingConstants;

import org.jxSwing.component.label.NumberLabel;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxSwing
 * @package org.jxSwing.component.table.cellRenderer
 * @date 31/03/2014 - 19:44:43
 */
public class NumericRenderer extends DefaultRenderer {
	
	private static final long serialVersionUID = 2690437634283844164L;
	
	private final NumberLabel numberLabel = new NumberLabel();
	
	/**
	 * 
	 */
	public NumericRenderer() {
	
		setHorizontalAlignment(SwingConstants.RIGHT);
	}
	
	/**
	 * @param value
	 * @return formated value or empty String
	 */
	@Override
	public String formatValue(final Object value) {
	
		numberLabel.setText(super.formatValue(value));
		
		return numberLabel.getText();
	}
	
	/**
	 * @return the decimalDigits
	 */
	public final int getDecimalDigits() {
	
		return numberLabel.getDecimalDigits();
	}
	
	/**
	 * @return the decimalSeparator
	 */
	public final char getDecimalSeparator() {
	
		return numberLabel.getDecimalSeparator();
	}
	
	/**
	 * @param decimalDigits
	 *        the decimalDigits to set
	 */
	public final void setDecimalDigits(final int decimalDigits) {
	
		numberLabel.setDecimalDigits(decimalDigits);
	}
	
	/**
	 * @param decimalSeparator
	 *        the decimalSeparator to set
	 */
	public final void setDecimalSeparator(final char decimalSeparator) {
	
		numberLabel.setDecimalSeparator(decimalSeparator);
	}
	
	/**
	 * @param money
	 */
	public final void setMoney(final boolean money) {
	
		numberLabel.setMoney(money);
	}
	
	/**
	 * @return is money
	 */
	public final boolean isMoney() {
	
		return numberLabel.isMoney();
	}
}
